<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义指令例子图片放大效果</title>
    <style type="text/css">
        img{
            width: 300px;
            height: 250px;
        }
        div{
            margin: 50px 0 50px 300px;
        }
        .img:hover{
            transform: scale(1.3);
            transition: 1s;
        }

    </style>
</head>
<body>
<div>
    <img class="img" src="./蝶祈.jpg" alt="">
</div>
<div id="app">
    <img src="./蝶祈.jpg" alt="" v-ani>
</div>
<script src="vue.js"></script>
<script>
    new Vue({
        el:'#app',
        data(){
            return {

            }
        },
        directives:{
            ani:{
                bind(el,binding,vNode){
                    //onmouseover 当鼠标移入时
                    el.onmouseover = function () {
                        el.style.transform = 'scale(1.2)';//扩大
                        el.style.transition = '1s';//时间
                    };
                    //onmouseover 当鼠标移出时
                    el.onmouseleave = function () {
                        el.style.transform = 'scale(1)';
                    };
                }
            }
        }
    })
</script>
</body>
</html>